/**
 * 生成UUID
 */
export function uuid() {
  let temp_url = URL.createObjectURL(new Blob());
  let uuid = temp_url.toString();
  URL.revokeObjectURL(temp_url);
  return uuid.substr(uuid.lastIndexOf('/') + 1);
}

/**根据对象下载对应json文件*/
export function downloadJson(myJson: any, filename: string) {
  let sJson = JSON.stringify(myJson, null, 2);
  let blob = new Blob([sJson], {type: 'application/json'});
  let url: any = window.URL.createObjectURL(blob);
  let element = document.createElement('a');
  element.setAttribute('href', url);
  element.setAttribute('download', filename);
  element.style.display = 'none';
  document.body.appendChild(element);
  element.click(); // simulate click
  document.body.removeChild(element);
}
